<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('任务列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label style="width: 100px;">用户快手号：</label>
                                <input type="text" name="kuaiNumber"/>
                            </li>
                            <li>
                                <label style="width: 100px;">快手ID：</label>
                                <input type="text" name="kuaiId"/>
                            </li>
                            <li>
                                <label>任务类型：</label>
                                <select name="type">
                                    <option value="评论">评论</option>
                                </select>
                            </li>
                            <li>
                                <label>任务速度：</label>
                                <select name="speed">
                                    <option value="">所有</option>
                                    <option value="0">一般</option>
                                    <option value="1">更快</option>
                                </select>
                            </li>
                            <li>
                                <label>是否置顶：</label>
                                <select name="isTop">
                                    <option value="">所有</option>
                                    <option value="1">置顶</option>
                                    <option value="0">不置顶</option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <!--<div class="btn-group-sm" id="toolbar" role="group">
               &lt;!&ndash; <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="whzj:task:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="whzj:task:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>&ndash;&gt;
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="whzj:task:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="whzj:task:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>-->
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('whzj:task:edit')}]];
        var removeFlag = [[${@permission.hasPermi('whzj:task:remove')}]];
        var prefix = ctx + "whzj/task";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "任务",
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'id',
                        title: '任务id',
                        visible: false
                    },
                    {
                        field: 'kuaiNumber',
                        title: '用户快手号'
                    },
                    {
                        field: 'kuaiId',
                        title: '快手ID'
                    },
                    {
                        field: 'type',
                        title: '任务类型'
                    },
                    {
                        field: 'imgUrl',
                        title: '图片连接',
                        formatter: function(value, row, index) {
                            var actions = [];
                            if(row.workId != null){
                                actions.push('<a  href="javascript:void(0)" onclick="openImage(\'' + row.imgUrl+ '\')">查看</a> ');
                            }
                            return actions.join('');
                        }
                    },
                    {
                        field: 'videoUrl',
                        title: '视频连接',
                        formatter: function(value, row, index) {
                            var actions = [];
                            if(row.workId != null){
                                actions.push('' +
                                    '<input id="workLink'+row.id+'" style="text-overflow:ellipsis;border:none;outline:none;" readonly type="text" value="'+row.workId+'">' +
                                    '<a style="color: darkblue" href="javascript:void(0)" onclick="copyText(\'workLink' + row.id+'\',\'' + row.type +'\',\'' + row.workId + '\');">复制链接</a> ');
                                actions.push('<a style="color: darkred" href="javascript:void(0)" onclick="openVideo(\'' + row.videoUrl + '\',\'' + row.type +'\',\'' + row.workId + '\')">查看视频</a> ');
                            }
                            return actions.join('');
                        }
                    },
                    {
                        field: 'allNum',
                        title: '总数量'
                    },
                    {
                        field: 'num',
                        title: '已完成数量'
                    },
                    {
                        field: 'status',
                        title: '状态'
                    },
                    {
                        field: 'speed',
                        title: '任务速度'
                    },
                    {
                        field: 'isTop',
                        title: '是否置顶'
                    },{
                        field: 'createTime',
                        title: '发布时间'
                    },
                    {
                        title: '操作',
                        align: 'center',
                        formatter: function(value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                            return actions.join('');
                        }
                    }]
            };
            $.table.init(options);
        });

        function openVideo(videoUrl,type,workId){
            debugger;
            /*if(type == "关注"){
                $.modal.open("查看视频", "http://kpfshanghai.m.chenzhongtech.com/fw/user/"+workId);
            }else{
                var openUrl = "http://kphbeijing.m.chenzhongtech.com/fw/photo/"+workId;
                $.modal.open("查看视频",openUrl );
            }*/
            window.open(workId)
        }

        function copyText(wId) {
            debugger;
            var text = document.getElementById(wId);
            text.select(); // 选中文本
            document.execCommand("copy"); // 执行浏览器复制命令
            $.modal.msgSuccess("复制成功");
        }


        function openImage(imageUrl){
            $.modal.open("查看", imageUrl);
        }
    </script>
</body>
</html>